package main

import "fmt"

//演示一个map的channel，存放10个 map[string]string
func main() {
	var mapChan chan map[string]string
	mapChan = make(chan map[string]string, 10)
	m1 := make(map[string]string)
	m1["1"] = "1"
	m1["2"] = "2"

	m2 := make(map[string]string)
	m2["3"] = "3"
	m2["4"] = "4"

	mapChan <- m1
	mapChan <- m2

	//不可以迭代，因为fatal error: all goroutines are asleep - deadlock!
	//程序中不再存在可能 存放的操作，所以不可能一直遍历下去
	// for v := range mapChan {
	// 	fmt.Printf("%v", v)
	// }

	m1Result := <-mapChan
	for i, v := range m1Result {
		fmt.Printf("%v %v \n", i, v)
	}
}
